﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace SQLTouch.Service.DataContracts
{
    [DataContract]
    public class QueryResultData
    {
        [DataMember]
        private readonly List<QueryResultColumnData> columns;
        private ReadOnlyCollection<QueryResultColumnData> columnsReadOnly;

        private QueryResultData()
        {

        }

        public QueryResultData(IEnumerable<QueryResultColumnData> columns)
        {
            this.columns = columns.ToList();
        }

        public ReadOnlyCollection<QueryResultColumnData> Columns
        {
            get
            {
                if (columnsReadOnly == null)
                {
                    columnsReadOnly = new ReadOnlyCollection<QueryResultColumnData>(columns);
                }
                return columnsReadOnly;
            }
        }
    }
}
